package cn.itcast.mapper;

import cn.itcast.pojo.Clazz;
import cn.itcast.pojo.PageInfo;
import cn.itcast.pojo.QuaryParma;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Mapper
public interface ClazzMapper {
    //插入班级信息
    @Insert("INSERT INTO clazz (id,name, room, begin_date, end_date, master_id, subject, create_time, update_time) VALUES (null,#{name}, #{room}, #{beginDate}, #{endDate}, #{masterId}, #{subject}, #{createTime}, #{updateTime})")
    public int addClazz(Clazz clazz);
    //根据id查找班级
    @Select("select * from clazz where id = #{id}")
    Clazz findById(Integer id);
    //更新班级信息
    @Update("update clazz set name = #{name} ,room = #{room}, update_time = #{updateTime} ,begin_date = #{beginDate} ,end_date = #{endDate},master_id = #{masterId},subject = #{subject} where id = #{id}")
    int upDate(Clazz clazz);
    //删除班级信息
    @Delete(("delete from clazz where id = #{id}"))
    int deleteById(int id);
    //分页查询
    List<Clazz> findByPage(QuaryParma quaryParma);
    //查询所有班级信息
    @Select("select * from clazz")
    List<Clazz> findAll();
}
